﻿using System;
using MCP.BL.Messages;

namespace MCP.BL
{
    /// <summary>
    /// Operation result is using when user need to be informed about some operation results and some data need to be returned, for example: getting data from db.
    /// </summary>
    public class OperationResult<T> : OperationResultBase where T : class
    {
        public T Result { get; private set; }

        #region Constructors

        private OperationResult(T result, bool success, Exception exception, params MessageBase[] messages)
            : base(success, exception, messages)
        {
            this.Result = result;
        }

        public OperationResult(T result, params MessageBase[] messages)
            : this(result, true, null, messages)
        {
        }

        public OperationResult(Exception exception, params MessageBase[] messages)
            : this(null, false, exception, messages)
        {
        }

        public OperationResult(params MessageBase[] messages)
            : this(null, false, null, messages)
        {
        }

        #endregion

        //public static OperationResult<T> GetSuccessfulResult(T result, params MessageBase[] messages)
        //{
        //    var operationResult = new OperationResult<T>(result, true, null, messages);
        //    return operationResult;
        //}

        //public static OperationResult<T> GetFailedResult(params MessageBase[] messages)
        //{
        //    var operationResult = new OperationResult<T>(null, false, null, messages);

        //    return operationResult;
        //}

        //public static new OperationResult<T> GetFailedResult(Exception exception, params MessageBase[] messages)
        //{
        //    var operationResult = new OperationResult<T>(null, false, exception, messages);

        //    return operationResult;
        //}
    }
}